#include <bits/stdc++.h>

#define eb emplace_back
#define ep emplace
#define fi first
#define se second
#define in read<int>()
#define lin read<ll>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }

const int N = 2e5 + 10;

int n, a[N], b[N], tot, m;
int ls[N << 5], rs[N << 5], val[N << 5], ndn, rt[N];

int copy(int t) { int x = ++ndn; ls[x] = ls[t], rs[x] = rs[t], val[x] = val[t]; return x; }

void pu(int o) { val[o] = val[ls[o]] + val[rs[o]]; }

void upd(int &x, int pos, int v, int l = 1, int r = tot) {
	x = copy(x); if(l == r) return val[x] += v, void(); int mid = l + r >> 1;
	if(pos <= mid) upd(ls[x], pos, v, l, mid); else upd(rs[x], pos, v, mid + 1, r); pu(x);
}

int query(int x, int y, int k, int l = 1, int r = tot) {
	//cerr << val[y] - val[x] << " | " << x << " " << y << " " << k << " " << l << " " << r << endl;
	if(l == r) return l; int mid = l + r >> 1;
	if(val[ls[y]] - val[ls[x]] >= k) return query(ls[x], ls[y], k, l, mid);
	else return query(rs[x], rs[y], k - (val[ls[y]] - val[ls[x]]), mid + 1, r);
}

int main() {
#ifdef YJR_2333_TEST
	freopen("1.in", "r", stdin);
#endif
	n = in, m = in; rep(i, 1, n) a[i] = b[i] = in;
	sort(b + 1, b + n + 1), tot = unique(b + 1, b + n + 1) - b - 1;
	rep(i, 1, n) a[i] = lower_bound(b + 1, b + tot + 1, a[i]) - b;
	rep(i, 1, n) rt[i] = rt[i - 1], upd(rt[i], a[i], 1);
	rep(i, 1, m) {
		int l = in, r = in, k = in;
		printf("%d\n", b[query(rt[l - 1], rt[r], k)]);
	}
	return 0;
}
